﻿#ifndef VIDEOLAYOUTWIDGET_H
#define VIDEOLAYOUTWIDGET_H

#include <QBasicTimer>
#include <QMap>
#include <QMutex>
#include <QWidget>

class QListWidgetItem;
class QMimeData;
class VideoWindow;


class VideoLayoutWidget : public QWidget
{
    Q_OBJECT
public:
    explicit VideoLayoutWidget(QWidget *parent = Q_NULLPTR);
    void getConfig(qint8 &mode, int &row, int &column);

    void handle_mic_state(const QMap<int, qint64> &mic_list, const QMap<qint64, QListWidgetItem*> &userItems);
    void handle_video(int micid, const QPixmap &pix);
    void handle_volume(int micid, int volume);

    QSize sizeHint() const;
protected:
    void resizeEvent(QResizeEvent *e);
    void timerEvent(QTimerEvent *e);
    void contextMenuEvent(QContextMenuEvent *e);
private:
    void doChange();
    void doLayout(const QSize &size);
    QMap<int, VideoWindow*> videoMapping;   //key: mic_id

    QMutex video_mutex;
    QVector<VideoWindow*> videos;
    QSize hint;
    QBasicTimer timer;

    qint8 mode;
    int row;
    int column;
};

#endif // VIDEOLAYOUTWIDGET_H
